package top100;

/**
 * @author Godc
 * @description
 */
public class Average {
    public static void main(String[] args) {
        Merge1Solution s = new Merge1Solution();
        s.merge(new int[]{1,2,3,0,0,0},3,new int[]{2,5,6},3);
    }
}
class AverageSolution {
    public double average(int[] salary) {
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double sum = 0;
        for(int i = 0;i<salary.length;i++){
            if(salary[i]>max) max = salary[i];
            else if(salary[i]<min) min = salary[i];
            sum+=salary[i];
        }
        sum = sum-max-min;
        return sum/(salary.length-2);
    }

}
class Merge1Solution {
    public void merge(int[] nums1, int m, int[] nums2, int n) {
        int i = m-1,j = n-1;
        int x = nums1.length-1;
        while(i>=0&&j>=0){
            if(nums2[j]>nums1[i]){
                nums1[x--] = nums2[j--];
            }else{
                nums1[x--] = nums1[i--];
            }
        }
        while(i>=0) nums1[x--] = nums1[i--];
        while(j>=0) nums1[x--] = nums2[j--];
    }
}